#! /usr/bin/python

import mathex

def main():
    layer = 1
    p = 3
    while 10*p >= layer*4+1:
        #expand 1 layer
        layer += 1
        t = (layer*2 + 1)**2
        p += sum([ mathex.isPrime(k) and 1 or 0 for k in 
              [t-layer*2,
               t-layer*4,
               t-layer*6]
              ])
    print layer*2+1
    
if __name__ == '__main__':
    main()
